def bubble_sort(nums, reverse=False):
    """冒泡排序

    :param nums: 数组
    :param reverse: 是否倒序
    """
    n = len(nums)
    for i in range(n - 1):
        change = False
        for j in range(n - i - 1):
            if nums[j] > nums[j + 1]:
                nums[j], nums[j + 1] = nums[j + 1], nums[j]
                change = True
        if not change:
            break


if __name__ == "__main__":
    import random
    import time

    # 生成随机数列
    lst = list(range(1, 10001))
    random.shuffle(lst)

    # 冒泡排序数列
    start_time = time.time()
    bubble_sort(lst)
    end_time = time.time()

    # 打印排序时间
    print("排序用时:", end_time - start_time)
    # 包含跳出:8.916845083236694
